<!DOCTYPE html>
<html lang=zh>
<head>
  <meta charset="utf-8">
  
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-transform" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no,email=no,adress=no">
  <!-- Color theme for statusbar -->
  <meta name="theme-color" content="#000000" />
  <!-- 强制页面在当前窗口以独立页面显示,防止别人在框架里调用页面 -->
  <meta http-equiv="window-target" content="_top" />
  
  
  <title>EOS中Restful服务的开发与调用 | 张占阳的博客</title>
  <meta name="description" content="开发Restful服务创建服务实现类创建一个class，添加下列注解和代码，配置接口访问的入口，需要注意的是Path中的路径必须是与web.xml中resteasyservlet配置的相同，否则将无法访问到接口，此处我们配置在&#x2F;rest&#x2F;services下   123456789101112131415161718192021222324252627282930313233343536373839">
<meta property="og:type" content="article">
<meta property="og:title" content="EOS中Restful服务的开发与调用">
<meta property="og:url" content="https://zzy521.com/posts/5a3d390e.html">
<meta property="og:site_name" content="张占阳的博客">
<meta property="og:description" content="开发Restful服务创建服务实现类创建一个class，添加下列注解和代码，配置接口访问的入口，需要注意的是Path中的路径必须是与web.xml中resteasyservlet配置的相同，否则将无法访问到接口，此处我们配置在&#x2F;rest&#x2F;services下   123456789101112131415161718192021222324252627282930313233343536373839">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://zzy521.com/img/image-20210220101202007.png">
<meta property="og:image" content="https://zzy521.com/img/image-20210220101724380.png">
<meta property="og:image" content="https://zzy521.com/img/image-20210220101923074.png">
<meta property="article:published_time" content="2021-01-20T09:21:05.000Z">
<meta property="article:modified_time" content="2021-02-25T09:21:15.115Z">
<meta property="article:author" content="张占阳">
<meta property="article:tag" content="EOS">
<meta property="article:tag" content="Rest接口">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://zzy521.com/img/image-20210220101202007.png">
  <!-- Canonical links -->
  <link rel="canonical" href="https://zzy521.com/posts/5a3d390e.html">
  
    <link rel="alternate" href="/atom.xml" title="张占阳的博客" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png" type="image/x-icon">
  
  
<link rel="stylesheet" href="/css/style.css">

  
  
  
  
<meta name="generator" content="Hexo 5.3.0"></head>


<body class="main-center" itemscope itemtype="http://schema.org/WebPage">
  <header class="header" itemscope itemtype="http://schema.org/WPHeader">
  <div class="slimContent">
    <div class="navbar-header">
      
      
      <div class="profile-block text-center">
        <a id="avatar" href="https://github.com/zzy2019520" target="_blank">
          <img class="img-circle img-rotate" src="/images/avatar.jpg" width="200" height="200">
        </a>
        <h2 id="name" class="hidden-xs hidden-sm">张占阳</h2>
        <h3 id="title" class="hidden-xs hidden-sm hidden-md">软件开发工程师</h3>
        <small id="location" class="text-muted hidden-xs hidden-sm"><i class="icon icon-map-marker"></i> 徐州, 中国</small>
      </div>
      
      <div class="search" id="search-form-wrap">

    <form class="search-form sidebar-form">
        <div class="input-group">
            <input type="text" class="search-form-input form-control" placeholder="搜索" />
            <span class="input-group-btn">
                <button type="submit" class="search-form-submit btn btn-flat" onclick="return false;"><i class="icon icon-search"></i></button>
            </span>
        </div>
    </form>
    <div class="ins-search">
  <div class="ins-search-mask"></div>
  <div class="ins-search-container">
    <div class="ins-input-wrapper">
      <input type="text" class="ins-search-input" placeholder="想要查找什么..." x-webkit-speech />
      <button type="button" class="close ins-close ins-selectable" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
    </div>
    <div class="ins-section-wrapper">
      <div class="ins-section-container"></div>
    </div>
  </div>
</div>


</div>
      <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#main-navbar" aria-controls="main-navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>
    <nav id="main-navbar" class="collapse navbar-collapse" itemscope itemtype="http://schema.org/SiteNavigationElement" role="navigation">
      <ul class="nav navbar-nav main-nav menu-highlight">
        
        
        <li class="menu-item menu-item-home">
          <a href="/.">
            
            <i class="icon icon-home-fill"></i>
            
            <span class="menu-title">首页</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-archives">
          <a href="/archives">
            
            <i class="icon icon-archives-fill"></i>
            
            <span class="menu-title">归档</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-categories">
          <a href="/categories">
            
            <i class="icon icon-folder"></i>
            
            <span class="menu-title">分类</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-tags">
          <a href="/tags">
            
            <i class="icon icon-tags"></i>
            
            <span class="menu-title">标签</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-about">
          <a href="/about">
            
            <i class="icon icon-cup-fill"></i>
            
            <span class="menu-title">关于</span>
          </a>
        </li>
        
      </ul>
      
	
    <ul class="social-links">
    	
        <li><a href="https://github.com/zzy2019520" target="_blank" title="Github" data-toggle=tooltip data-placement=top><i class="icon icon-github"></i></a></li>
        
        <li><a href="https://weibo.com/u/6000361757" target="_blank" title="Weibo" data-toggle=tooltip data-placement=top><i class="icon icon-weibo"></i></a></li>
        
    </ul>

    </nav>
  </div>
</header>

  
    <aside class="sidebar" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    
      <div class="widget">
    <h3 class="widget-title">公告</h3>
    <div class="widget-body">
        <div id="board">
            <div class="content">
                <p>欢迎交流与分享经验!</p>
            </div>
        </div>
    </div>
</div>

    
      
  <div class="widget">
    <h3 class="widget-title">分类</h3>
    <div class="widget-body">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Java/">Java</a><span class="category-list-count">3</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/Python/">Python</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/">开发工具</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%96%87%E7%AB%A0%E5%88%86%E7%B1%BB/">文章分类</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E6%9C%8D%E5%8A%A1%E5%99%A8/">服务器</a><span class="category-list-count">4</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">标签</h3>
    <div class="widget-body">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/EOS/" rel="tag">EOS</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Hexo/" rel="tag">Hexo</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Java/" rel="tag">Java</a><span class="tag-list-count">4</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Linux/" rel="tag">Linux</a><span class="tag-list-count">3</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Rest%E6%8E%A5%E5%8F%A3/" rel="tag">Rest接口</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/SQLServer/" rel="tag">SQLServer</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Tomcat/" rel="tag">Tomcat</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/a/" rel="tag">a++</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/excel/" rel="tag">excel</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/exe/" rel="tag">exe</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/java/" rel="tag">java</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/markdown/" rel="tag">markdown</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/" rel="tag">python</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E4%BD%8D%E8%BF%90%E7%AE%97/" rel="tag">位运算</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%95%B0%E6%8D%AE%E5%BA%93/" rel="tag">数据库</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E6%96%87%E7%AB%A0%E6%A0%87%E7%AD%BE/" rel="tag">文章标签</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2/" rel="tag">类型转换</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E9%92%89%E9%92%89%E6%B6%88%E6%81%AF/" rel="tag">钉钉消息</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E9%A1%B9%E7%9B%AE%E8%AF%B4%E6%98%8E/" rel="tag">项目说明</a><span class="tag-list-count">1</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">标签云</h3>
    <div class="widget-body tagcloud">
      <a href="/tags/EOS/" style="font-size: 13.67px;">EOS</a> <a href="/tags/Hexo/" style="font-size: 13px;">Hexo</a> <a href="/tags/Java/" style="font-size: 14px;">Java</a> <a href="/tags/Linux/" style="font-size: 13.67px;">Linux</a> <a href="/tags/Rest%E6%8E%A5%E5%8F%A3/" style="font-size: 13px;">Rest接口</a> <a href="/tags/SQLServer/" style="font-size: 13px;">SQLServer</a> <a href="/tags/Tomcat/" style="font-size: 13.33px;">Tomcat</a> <a href="/tags/a/" style="font-size: 13px;">a++</a> <a href="/tags/excel/" style="font-size: 13px;">excel</a> <a href="/tags/exe/" style="font-size: 13px;">exe</a> <a href="/tags/java/" style="font-size: 13px;">java</a> <a href="/tags/markdown/" style="font-size: 13px;">markdown</a> <a href="/tags/python/" style="font-size: 13px;">python</a> <a href="/tags/%E4%BD%8D%E8%BF%90%E7%AE%97/" style="font-size: 13px;">位运算</a> <a href="/tags/%E6%95%B0%E6%8D%AE%E5%BA%93/" style="font-size: 13px;">数据库</a> <a href="/tags/%E6%96%87%E7%AB%A0%E6%A0%87%E7%AD%BE/" style="font-size: 13px;">文章标签</a> <a href="/tags/%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2/" style="font-size: 13px;">类型转换</a> <a href="/tags/%E9%92%89%E9%92%89%E6%B6%88%E6%81%AF/" style="font-size: 13px;">钉钉消息</a> <a href="/tags/%E9%A1%B9%E7%9B%AE%E8%AF%B4%E6%98%8E/" style="font-size: 13px;">项目说明</a>
    </div>
  </div>

    
      
  <div class="widget">
    <h3 class="widget-title">归档</h3>
    <div class="widget-body">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/05/">五月 2021</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/04/">四月 2021</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/03/">三月 2021</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/02/">二月 2021</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/01/">一月 2021</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/12/">十二月 2020</a><span class="archive-list-count">3</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget-body">
      <ul class="recent-post-list list-unstyled no-thumbnail">
        
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/categories/%E6%96%87%E7%AB%A0%E5%88%86%E7%B1%BB/">文章分类</a>
              </p>
              <p class="item-title">
                <a href="/posts/ab81ff07.html" class="title">CRM调用外部接口</a>
              </p>
              <p class="item-date">
                <time datetime="2021-05-18T01:48:01.000Z" itemprop="datePublished">2021-05-18</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/categories/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/">开发工具</a>
              </p>
              <p class="item-title">
                <a href="/posts/6a850357.html" class="title">调用钉钉接口发送工作通知</a>
              </p>
              <p class="item-date">
                <time datetime="2021-04-07T03:21:19.000Z" itemprop="datePublished">2021-04-07</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/categories/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/">开发工具</a>
              </p>
              <p class="item-title">
                <a href="/posts/21754c85.html" class="title">解决NavicatPremium连接SQLServer出现未发现数据源名称并且未指定默认驱动</a>
              </p>
              <p class="item-date">
                <time datetime="2021-03-30T02:34:02.000Z" itemprop="datePublished">2021-03-30</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/categories/Java/">Java</a>
              </p>
              <p class="item-title">
                <a href="/posts/dad1e78f.html" class="title">Java中a=a++的问题</a>
              </p>
              <p class="item-date">
                <time datetime="2021-03-23T09:41:17.000Z" itemprop="datePublished">2021-03-23</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/categories/Java/">Java</a>
              </p>
              <p class="item-title">
                <a href="/posts/f789481e.html" class="title">Java位运算</a>
              </p>
              <p class="item-date">
                <time datetime="2021-03-23T02:05:47.000Z" itemprop="datePublished">2021-03-23</time>
              </p>
            </div>
          </li>
          
      </ul>
    </div>
  </div>
  

    
  </div>
</aside>

  
  
<aside class="sidebar sidebar-toc collapse" id="collapseToc" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    <nav id="toc" class="article-toc">
      <h3 class="toc-title">文章目录</h3>
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%BC%80%E5%8F%91Restful%E6%9C%8D%E5%8A%A1"><span class="toc-number">1.</span> <span class="toc-text">开发Restful服务</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E6%9C%8D%E5%8A%A1%E5%AE%9E%E7%8E%B0%E7%B1%BB"><span class="toc-number">1.1.</span> <span class="toc-text">创建服务实现类</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-number">2.</span> <span class="toc-text">创建配置文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BC%96%E8%BE%91web-xml%E6%96%87%E4%BB%B6"><span class="toc-number">3.</span> <span class="toc-text">编辑web.xml文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9%EF%BC%9A"><span class="toc-number">4.</span> <span class="toc-text">注意事项：</span></a></li></ol>
    </nav>
  </div>
</aside>

<main class="main" role="main">
  <div class="content">
  <article id="post-EOS实现restful" class="article article-type-post" itemscope itemtype="http://schema.org/BlogPosting">
    
    <div class="article-header">
      
        
  
    <h1 class="article-title" itemprop="name">
      EOS中Restful服务的开发与调用
    </h1>
  

      
      <div class="article-meta">
        <span class="article-date">
    <i class="icon icon-calendar-check"></i>
	<a href="/posts/5a3d390e.html" class="article-date">
	  <time datetime="2021-01-20T09:21:05.000Z" itemprop="datePublished">2021-01-20</time>
	</a>
</span>
        
  <span class="article-category">
    <i class="icon icon-folder"></i>
    <a class="article-category-link" href="/categories/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/">开发工具</a>
  </span>

        
  <span class="article-tag">
    <i class="icon icon-tags"></i>
	<a class="article-tag-link-link" href="/tags/EOS/" rel="tag">EOS</a>, <a class="article-tag-link-link" href="/tags/Rest%E6%8E%A5%E5%8F%A3/" rel="tag">Rest接口</a>
  </span>


        
	<span class="article-read hidden-xs">
	    <i class="icon icon-eye-fill" aria-hidden="true"></i>
	    <span id="busuanzi_container_page_pv">
			<span id="busuanzi_value_page_pv">0</span>
		</span>
	</span>


        <span class="post-comment"><i class="icon icon-comment"></i> <a href="/posts/5a3d390e.html#comments" class="article-comment-link">评论</a></span>
        
	
		<span class="post-wordcount hidden-xs" itemprop="wordCount">字数统计: 747(字)</span>
	
	
		<span class="post-readcount hidden-xs" itemprop="timeRequired">阅读时长: 3(分)</span>
	

      </div>
    </div>
    <div class="article-entry marked-body" itemprop="articleBody">
      
        <h2 id="开发Restful服务"><a href="#开发Restful服务" class="headerlink" title="开发Restful服务"></a>开发Restful服务</h2><h3 id="创建服务实现类"><a href="#创建服务实现类" class="headerlink" title="创建服务实现类"></a>创建服务实现类</h3><p>创建一个class，添加下列注解和代码，配置接口访问的入口，需要注意的是Path中的路径必须是与web.xml中resteasyservlet配置的相同，否则将无法访问到接口，此处我们配置在/rest/services下</p>
<img src="../img/image-20210220101202007.png" alt="image-20210220101202007" style="zoom:50%;" />

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> com.xcmg.service;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.util.*;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> javax.sql.DataSource;</span><br><span class="line"><span class="keyword">import</span> javax.ws.rs.GET;</span><br><span class="line"><span class="keyword">import</span> javax.ws.rs.POST;</span><br><span class="line"><span class="keyword">import</span> javax.ws.rs.Path;</span><br><span class="line"><span class="keyword">import</span> javax.ws.rs.PathParam;</span><br><span class="line"><span class="keyword">import</span> javax.ws.rs.Produces;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> com.alibaba.fastjson.JSON;</span><br><span class="line"><span class="keyword">import</span> com.eos.common.connection.DataSourceHelper;</span><br><span class="line"><span class="keyword">import</span> com.eos.engine.component.ILogicComponent;</span><br><span class="line"><span class="keyword">import</span> com.eos.foundation.data.DataObjectUtil;</span><br><span class="line"><span class="keyword">import</span> com.eos.workflow.api.BPSServiceClientFactory;</span><br><span class="line"><span class="keyword">import</span> com.primeton.components.rest.annotation.JSONParam;</span><br><span class="line"><span class="keyword">import</span> com.primeton.ext.engine.component.LogicComponentFactory;</span><br><span class="line"><span class="keyword">import</span> com.xcmg.getRsInfo;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> commonj.sdo.DataObject;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="meta">@Path(&quot;/rest/services/RoleService&quot;)</span></span><br><span class="line"><span class="meta">@Produces(&#123;&quot;application/json&quot;&#125;)</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ProcessStartService</span> </span>&#123;</span><br><span class="line">	</span><br><span class="line">	<span class="meta">@POST</span></span><br><span class="line">	<span class="meta">@Path(&quot;/addProcess&quot;)</span></span><br><span class="line">	<span class="comment">//新增数据</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span>  String  <span class="title">addRole</span><span class="params">(<span class="meta">@JSONParam(&quot;role&quot;)</span>DataObject[] role)</span><span class="keyword">throws</span> Throwable</span>&#123;</span><br><span class="line">		<span class="comment">//获取后台返回值</span></span><br><span class="line">		Map ms= <span class="keyword">new</span> HashMap();</span><br><span class="line">		<span class="comment">//调用数据模型									   </span></span><br><span class="line">		role = DataObjectUtil.convertDataObjects(role,<span class="string">&quot;com.primeton.eos.Advice.Advice&quot;</span>,<span class="keyword">false</span>);</span><br><span class="line">		System.err.println(role.length);</span><br><span class="line">		<span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; role.length; i++) &#123;</span><br><span class="line">			Object[] inParameters = &#123;</span><br><span class="line">									role[i].get(<span class="string">&quot;proposer&quot;</span>),</span><br><span class="line">									role[i].get(<span class="string">&quot;department&quot;</span>),</span><br><span class="line">									role[i].get(<span class="string">&quot;phone&quot;</span>),</span><br><span class="line">									role[i].get(<span class="string">&quot;category&quot;</span>),</span><br><span class="line">									role[i].get(<span class="string">&quot;carrydepartment&quot;</span>),</span><br><span class="line">									role[i].get(<span class="string">&quot;proposal&quot;</span>),</span><br><span class="line">									role[i].get(<span class="string">&quot;actuality&quot;</span>),</span><br><span class="line">									role[i].get(<span class="string">&quot;improvement&quot;</span>)</span><br><span class="line">									&#125;;</span><br><span class="line">			<span class="comment">//打印数据</span></span><br><span class="line">			Object[] params = <span class="keyword">new</span> Object[<span class="number">1</span>];</span><br><span class="line">			params[<span class="number">0</span>] = role;</span><br><span class="line">			Object[] result = <span class="keyword">null</span>;</span><br><span class="line">			<span class="comment">//设置登录用户</span></span><br><span class="line">			String userid= (String)role[i].get(<span class="string">&quot;state&quot;</span>);</span><br><span class="line">			BPSServiceClientFactory.getLoginManager().setCurrentUser(userid, <span class="string">&quot;sysadmin&quot;</span>);</span><br><span class="line">			</span><br><span class="line">							<span class="comment">//构件名称</span></span><br><span class="line">			ILogicComponent logicComponent = LogicComponentFactory.create(<span class="string">&quot;com.primeton.eos.phoneProcess&quot;</span>);</span><br><span class="line">											<span class="comment">//逻辑流名称</span></span><br><span class="line">			result = logicComponent.invoke(<span class="string">&quot;StartProcess&quot;</span>, inParameters);</span><br><span class="line">			String count = (String)result[<span class="number">0</span>];</span><br><span class="line">			Long id = (Long)result[<span class="number">1</span>];</span><br><span class="line">			System.err.println(<span class="string">&quot;-----------------------》》&quot;</span>+count);</span><br><span class="line">			<span class="keyword">if</span>(count.equals(<span class="string">&quot;1&quot;</span>))&#123;</span><br><span class="line">				ms.put(<span class="string">&quot;errorCode&quot;</span>,<span class="string">&quot;00100&quot;</span>);</span><br><span class="line">				ms.put(<span class="string">&quot;errorMsg&quot;</span>, <span class="string">&quot;新增数据成功&quot;</span>);</span><br><span class="line">				ms.put(<span class="string">&quot;value&quot;</span>,id);</span><br><span class="line">			&#125;<span class="keyword">else</span>&#123;</span><br><span class="line">				<span class="comment">//更新数据</span></span><br><span class="line">				ms.put(<span class="string">&quot;errorCode&quot;</span>,<span class="string">&quot;00200&quot;</span>);</span><br><span class="line">				ms.put(<span class="string">&quot;errorMsg&quot;</span>, <span class="string">&quot;新增数据失败&quot;</span>);</span><br><span class="line">				ms.put(<span class="string">&quot;value&quot;</span>,<span class="string">&quot;&quot;</span>);</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">return</span>  JSON.toJSONString(ms);</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	<span class="meta">@GET</span></span><br><span class="line">	<span class="meta">@Path(&quot;/getProcess/&#123;productCode&#125;&quot;)</span></span><br><span class="line">	<span class="comment">//查询数据是否存在</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> String <span class="title">selectEngineNumberInfoCount</span><span class="params">(<span class="meta">@PathParam(&quot;productCode&quot;)</span>String productCode)</span> <span class="keyword">throws</span> Throwable</span>&#123;</span><br><span class="line">		Map ms= <span class="keyword">new</span> HashMap();</span><br><span class="line">		DataSource db = DataSourceHelper.getDataSource(<span class="string">&quot;default&quot;</span>);</span><br><span class="line">		<span class="comment">//查询用户</span></span><br><span class="line">		String vininfo = <span class="string">&quot;SELECT a.PROCESSINSTID,a.PROPOSER,b.NAME DEPARTMENT,a.PHONE,c.NAME CATEGORY,d.NAME CARRYDEPARTMENT,a.PROPOSAL,a.ACTUALITY,a.IMPROVEMENT,a.SUBMITTIME,a.OPINION1,a.CHECKTIME,a.OPINION2,a.RECHECKTIME,a.STATE FROM ((ADVICE a LEFT JOIN DEPARTMENT b ON a.DEPARTMENT=b.DID)LEFT JOIN CATEGORY c ON a.CATEGORY=c.ID)LEFT JOIN CARRYDEPARTMENT d ON a.CARRYDEPARTMENT=d.ID WHERE PHONE = &#x27;&quot;</span>+productCode+<span class="string">&quot;&#x27; ORDER BY PROCESSINSTID DESC&quot;</span>;		<span class="comment">//获取密码</span></span><br><span class="line">		List list = getRsInfo.getRsListbySql(vininfo, db.getConnection());</span><br><span class="line">		</span><br><span class="line">		<span class="keyword">return</span>  JSON.toJSONString(list);</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="创建配置文件"><a href="#创建配置文件" class="headerlink" title="创建配置文件"></a>创建配置文件</h2><p>在编辑的java同目录下创建文件restconfig.properties并录入以下内容（等号后是对应的类全名）</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">resteasy.resources&#x3D;com.xcmg.service.ProcessStartService</span><br></pre></td></tr></table></figure>
<img src="../img/image-20210220101724380.png" alt="image-20210220101724380" style="zoom: 50%;" />

<h2 id="编辑web-xml文件"><a href="#编辑web-xml文件" class="headerlink" title="编辑web.xml文件"></a>编辑web.xml文件</h2><p>编辑web.xml文件，在rest.config.locations下的param-value标签下新增restconfig.properties对应路径，需要增加英文逗号与已有内容分开，保存编辑后需要右键web.xml文件进行部署。</p>
<img src="../img/image-20210220101923074.png" alt="image-20210220101923074" style="zoom:50%;" />

<h2 id="注意事项："><a href="#注意事项：" class="headerlink" title="注意事项："></a>注意事项：</h2><p><strong>1.修改了web.xml要手动部署web.xml</strong><br><strong>2.web.xml中的servlet-mapping下的url-pattern要和配置访问的地址对应</strong><br><strong>3.在rest.config.locations下的param-value标签下新增restconfig.properties对应路径</strong></p>

      
    </div>
    <div class="article-footer">
      <blockquote class="mt-2x">
  <ul class="post-copyright list-unstyled">
    
    <li class="post-copyright-link hidden-xs">
      <strong>本文链接：</strong>
      <a href="https://zzy521.com/posts/5a3d390e.html" title="EOS中Restful服务的开发与调用" target="_blank" rel="external">https://zzy521.com/posts/5a3d390e.html</a>
    </li>
    
    <li class="post-copyright-license">
      <strong>版权声明： </strong> 本博客所有文章除特别声明外，均采用 <a href="http://creativecommons.org/licenses/by/4.0/deed.zh" target="_blank" rel="external">CC BY 4.0 CN协议</a> 许可协议。转载请注明出处！
    </li>
  </ul>
</blockquote>


<div class="panel panel-default panel-badger">
  <div class="panel-body">
    <figure class="media">
      <div class="media-left">
        <a href="https://github.com/zzy2019520" target="_blank" class="img-burn thumb-sm visible-lg">
          <img src="/images/avatar.jpg" class="img-rounded w-full" alt="">
        </a>
      </div>
      <div class="media-body">
        <h3 class="media-heading"><a href="https://github.com/zzy2019520" target="_blank"><span class="text-dark">张占阳</span><small class="ml-1x">软件开发工程师</small></a></h3>
        <div>能吃能睡，啥都不会！</div>
      </div>
    </figure>
  </div>
</div>


    </div>
  </article>
  
    
  <section id="comments">
  	
      <div id="vcomments"></div>
    
  </section>


  
</div>

  <nav class="bar bar-footer clearfix" data-stick-bottom>
  <div class="bar-inner">
  
  <ul class="pager pull-left">
    
    <li class="prev">
      <a href="/posts/eeae6a0e.html" title="将Java程序打包为exe文件并和jre一起打包为安装包"><i class="icon icon-angle-left" aria-hidden="true"></i><span>&nbsp;&nbsp;上一篇</span></a>
    </li>
    
    
    <li class="next">
      <a href="/posts/7067bb35.html" title="Markdown生成带侧边目录的HTML"><span>下一篇&nbsp;&nbsp;</span><i class="icon icon-angle-right" aria-hidden="true"></i></a>
    </li>
    
    
    <li class="toggle-toc">
      <a class="toggle-btn collapsed" data-toggle="collapse" href="#collapseToc" aria-expanded="false" title="文章目录" role="button">
        <span>[&nbsp;</span><span>文章目录</span>
        <i class="text-collapsed icon icon-anchor"></i>
        <i class="text-in icon icon-close"></i>
        <span>]</span>
      </a>
    </li>
    
  </ul>
  
  
  <!-- Button trigger modal -->
  <button type="button" class="btn btn-fancy btn-donate pop-onhover bg-gradient-warning" data-toggle="modal" data-target="#donateModal"><span>赏</span></button>
  <!-- <div class="wave-icon wave-icon-danger btn-donate" data-toggle="modal" data-target="#donateModal">
    <div class="wave-circle"><span class="icon"><i class="icon icon-bill"></i></span></div>
  </div> -->
  
  
  <div class="bar-right">
    
  </div>
  </div>
</nav>
  
<!-- Modal -->
<div class="modal modal-center modal-small modal-xs-full fade" id="donateModal" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content donate">
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      <div class="modal-body">
        <div class="donate-box">
          <div class="donate-head">
            <p>感谢您的支持，我会继续努力的!</p>
          </div>
          <div class="tab-content">
            <div role="tabpanel" class="tab-pane fade active in" id="alipay">
              <div class="donate-payimg">
                <img src="/images/donate/alipay.jpg" alt="扫码支持" title="扫一扫" />
              </div>
              <p class="text-muted mv">扫码打赏，你说多少就多少</p>
              <p class="text-grey">打开支付宝扫一扫，即可进行扫码打赏哦</p>
            </div>
            <div role="tabpanel" class="tab-pane fade" id="wechatpay">
              <div class="donate-payimg">
                <img src="/images/donate/wechat.png" alt="扫码支持" title="扫一扫" />
              </div>
              <p class="text-muted mv">扫码打赏，你说多少就多少</p>
              <p class="text-grey">打开微信扫一扫，即可进行扫码打赏哦</p>
            </div>
          </div>
          <div class="donate-footer">
            <ul class="nav nav-tabs nav-justified" role="tablist">
              <li role="presentation" class="active">
                <a href="#alipay" id="alipay-tab" role="tab" data-toggle="tab" aria-controls="alipay" aria-expanded="true"><i class="icon icon-alipay"></i> 支付宝</a>
              </li>
              <li role="presentation" class="">
                <a href="#wechatpay" role="tab" id="wechatpay-tab" data-toggle="tab" aria-controls="wechatpay" aria-expanded="false"><i class="icon icon-wepay"></i> 微信支付</a>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>



</main>

  <footer class="footer" itemscope itemtype="http://schema.org/WPFooter">
	
	
    <ul class="social-links">
    	
        <li><a href="https://github.com/zzy2019520" target="_blank" title="Github" data-toggle=tooltip data-placement=top><i class="icon icon-github"></i></a></li>
        
        <li><a href="https://weibo.com/u/6000361757" target="_blank" title="Weibo" data-toggle=tooltip data-placement=top><i class="icon icon-weibo"></i></a></li>
        
    </ul>

    <div class="copyright">
    	
        &copy; 2021 张占阳
        
        <div class="publishby">
            本网站由<a href="https://www.upyun.com/?utm_source=lianmeng&utm_medium=referral" target="_blank"><img width="40" src="../img/又拍云_logo5.png"/> </a>提供存储服务
        	<!-- Theme by <a href="https://github.com/cofess" target="_blank"> cofess </a>base on <a href="https://github.com/cofess/hexo-theme-pure" target="_blank">pure</a>. -->
        </div>
    </div>
</footer>
  <script src="//cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script>
window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')
</script>

<script src="/js/plugin.min.js"></script>


<script src="/js/application.js"></script>


    <script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: '文章',
            PAGES: '页面',
            CATEGORIES: '分类',
            TAGS: '标签',
            UNTITLED: '(未命名)',
        },
        ROOT_URL: '/',
        CONTENT_URL: '/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>

<script src="/js/insight.js"></script>






   
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>





   
    
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/valine"></script>
  <script type="text/javascript">
  var GUEST = ['nick', 'mail', 'link'];
  var meta = 'nick,mail,link';
  meta = meta.split(',').filter(function(item) {
    return GUEST.indexOf(item) > -1;
  });
  new Valine({
    el: '#vcomments',
    verify: false,
    notify: false,
    appId: 'SVT1dStIdP36PNVntBfpuIAa-gzGzoHsz',
    appKey: 'wXS1sNhJ0U7pxRdcjaxUCJIk',
    placeholder: '填写评论',
    avatar: 'mm',
    meta: meta,
    pageSize: '10' || 10,
    visitor: false
  });
  </script>

     







</body>
</html>